<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <title>应急信息发布项目维护添加</title>
    
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet" type="text/css">
    <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="../../css/style.css" rel="stylesheet" type="text/css">
    <link href="../../css/jquery-ui-1.10.4.custom.min.css" rel="stylesheet" type="text/css">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.js"></script>
    <script src="../../js/util.js"></script>
    <script src="../../js/jquery-ui-1.10.4.custom.min.js"></script>
    <link href="../../layui/formSelects-v4.css" rel="stylesheet" />
	<script src="../../layui/formSelects-v4.js"></script>
    
    <script>
        layui.use(['table', 'form', 'jquery', 'element','layer','laydate'], function () {
            var table = layui.table;
            var form = layui.form;
            var $ = layui.$;
            var layer=layui.layer;
            var user;
            var flagMgr;
            var laydate = layui.laydate;
            var mapManage = "/mapManage.html";
	        laydate.render({
	             elem: '#startTime'
	             , type: 'datetime'
	             ,min:minDate()
	        });
	        laydate.render({
	             elem: '#endTime'
	             , type: 'datetime'
	             ,min:minDate()
	        });

            //监听阀值是否勾选控制阀值数值是否可输入
            form.on('checkbox(thresholdSwitch)', function (data) {
                console.log( data );　　//打印当前选择的信息
                if( data.elem.checked){　　　　　　//判断当前多选框是选中还是取消选中
                    $("#threshold").attr("disabled",false);
                    layui.form.render();
                }else{
                    $("#threshold").attr("disabled", true);
                    layui.form.render();
                }
            });


            form.on('checkbox(cycleThresholdSwitch)', function (data) {
                console.log( data );　　//打印当前选择的信息
                if( data.elem.checked){　　　　　　//判断当前多选框是选中还是取消选中
                    $("#cycleThreshold").attr("disabled",false);
                    layui.form.render();
                }else{
                    $("#cycleThreshold").attr("disabled", true);
                    layui.form.render();
                }
            });


            function minDate(){
			    var now = new Date();
			    return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate()+" "+now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();
			}
			
			form.on("radio(gis)", function (data) {
				chooseSendLimitType();
		    });
			
			//根据城市ID查询扩展码
            function selectExtInfo(cityId) {
                var data;
                var url = '/util/findExdId?cityId=' + cityId;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            console.log(json.data);
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
            //动态拼接扩展码
            function appendExtId(data) {
                if (data.length != null) {
                    var options = '<option value="">请选择</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i] + '">' + data[i] + '</option>';
                    }
                    $('#extId').html(options);
                } else {
                    $('#extId').html('<option value="">该地市下没有扩展码</option>');
                }
                form.render();
            }
            //监听区县
            form.on('select(cityId)', function (data) {
                var data2 = selectCountyId(data.value);
                appendCounty(data2);
                //appendCountyCheckBox(data2);
                var data3 = selectExtInfo(data.value);
                appendExtId(data3);
            });
            //根据城市ID查询区县
            function selectCountyId(cityId) {
                var data;
                var url = '/util/findCountyByCityId?cityId=' + cityId;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
            //动态拼接区县
            function appendCounty(data){
                if (data.length != null) {
                    var options = '<option value="">请选择</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].countyId + '">' + data[i].countyName + '</option>';
                    }
                    $('#countyId').html(options);
                } else {
                    $('#countyId').html('该地市下没有区县');
                }
                form.render();
            }            
            
            

            function qryPathName() {
                var data;
                var url = '/smsArea/findPathName';
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                            if (data.length != null) {
                    		var options = '<option value="all">全部</option>';
                    			for (var i = 0; i < data.length; i++) {
                    				//console.info(data[i]);
                        			options += '<option value="' + data[i] + '">' + data[i] + '</option>';
                    			}
                    			$('#pathName').html(options);
                			} else {
                    			$('#pathName').html('暂无路线信息');
                			}
                form.render();
                            
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
            
            form.on('select(pathName)', function (data) {
                var subStationList=selectRegionName(data.value);
                appendSubStationNames(subStationList);
            });
            
            function selectRegionName(pathName) {
                var data;
                var url = '/smsArea/findRegionName?pathName=' + pathName;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
            
             function appendSubStationNames(data){
                if (data.length != null) {
                    var options = '<option value="all">全部</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i]+ '">' + data[i] + '</option>';
                    }
                    $('#subStationName').html(options);
                } else {
                    $('#subStationName').html('该路线下暂无点位');
                }
                form.render();
    		}
    
    			$("#regionName").autocomplete({
    			source : function(request, response) {
    				var pathName = $("#pathName").val();
    				var regionName = $("#regionName").val();
    				if("all"===pathName){
    					pathName="";
    				}
    				console.info(regionName);
    				var url = '/smsArea/findRegionNameLike';
    				var param = {
    					pathName : pathName,
    					regionName : regionName
    				};
    				$.ajax({
    					type : 'post',
    					async : false,
    					url : url,
    					data : param,
    					success : function(json) {
    						var data = json.data;
    						source = [];
    						for (var i = 0; i < data.length; i++) {
    							source[i] = data[i];
    						}
    						console.log(source);
    						response(source);
    					},
    					error : function() {
    						layer.msg('系统异常，请联系管理员处理!');
    					}
    				}
    				);
    			},
    			messages : { //message设置不出现匹配关键字的结果
    				noResults : '',
    				results : function() {}
    			}
    		});
    
    
    		//监听项目
    		form.on('select(countyId)', function (data) {
                //var data1 = selectMgrInfo(data.value);
                //appendMgr(data1);
            });
            //根据城市ID和区县查询项目
            function selectMgrInfo(countyId) {
                var data;
                var url = '/util/findByMgrId?countyId=' + countyId;
                $.ajax({
                        type: 'post',
                        async: false,
                        url: url,
                        success: function (json) {
                            data = json.data;
                        }, error: function () {
                            layer.msg('系统异常，请联系管理员处理!');
                        }
                    }
                );
                return data;
            }
            //动态拼接项目
            function appendMgr(data) {
                if (data.length != null) {
                    var options = '<option value="">请选择</option>';
                    for (var i = 0; i < data.length; i++) {
                        options += '<option value="' + data[i].id + '">' + data[i].name + '</option>';
                    }
                    $('#mgrId').html(options);
                } else {
                    $('#mgrId').html('<option value="">该区县下没有项目</option>');
                }
                form.render();
            }
            
            
            
            $('#query').on('click', function () {
  	       		var pathName=$("#pathName").val();
  	       		console.info(pathName);
  	       		
  	       		var subStationName=$("#subStationName").val();
  	       		var subStationNameText = $("#regionName").val();
  	       		if(isNull(subStationNameText)){
  	       			console.info("xuanze");
  	       		}else{
  	       			console.info("tainxie");
  	       			subStationName = subStationNameText;
  	       		}
  	       		var mgrId=xiangmuId;
	            var startTime=$("#startTime").val();
                var endTime=$("#endTime").val();
                var countyId = $("#countyId").val();
                var regionName = $("#countyId option:selected").text();
	            var isChooseMap = $("input[name='isChooseMap']:checked").val();
	            var cityId=$("#cityId").val();
	            if(isNull(cityId)){
                    cityId="25";
                }
                if(isNull(mgrId)){
                    layer.msg("未获取到项目编号，请重新加载");
                    return false;
                }
                
                if (subStationName == null || subStationName== "") {
                            layer.msg("点位信息不能为空");
                            return false;
                        }
  	       		//console.info("----"+pathName+"---"+subStationName);
  	       		var url="../areaManage"+mapManage+"?cityId="+cityId+"&mgrId="+mgrId+"&sendStart="+startTime+"&sendEnd="+endTime
		            		+"&scopeType="+isChooseMap+"&mgrState="+"2"+"&checkState="+"2"+"&flag="+"insert";
		          	
	                
	                if(null!=countyId&&''!=countyId){
		          		url = url +"&countyId="+countyId;
	                }
	                if(null!=regionName&&''!=regionName){
	                	url = url +"&regionName="+encodeURI(regionName);
	                }
	                
	                if(null!=subStationName&&''!=subStationName){
		          		url = url +"&subStationName="+encodeURI(subStationName);
	                }
	                if(null!=pathName&&''!=pathName){
	                	url = url +"&pathName="+encodeURIComponent(pathName);
	                }
	                url=encodeURI(url); 
		            $('iframe').attr('src', url);
            });
  
            //获取mgr序列
            var xiangmuId;
			function getMgrId() {
			    var url = '/util/getMgrId';
			    $.ajax({
			            url: url,
			            type: 'post',
			            success: function (json) {
			                xiangmuId = json.data;
			            }, error: function () {
			                layer.msg('系统异常，请联系管理员处理!');
			            }
			        }
			    );
			}
			
			//判断项目名称是否重复
			function judgeMgrName(mgrName){
				var url = '/util/getMgrName';
			    $.ajax({
			            url: url,
			            type: 'post',
			            async: false,
			            data: "mgrName="+mgrName,
			            success: function (json) {
			                flagMgr = json.data;
			            }, error: function () {
			                layer.msg('系统异常，请联系管理员处理!');
			            }
			        }
			    );
			}
            //跳转地图
            $('#ditubtn').on('click', function () {
	            var mgrId=xiangmuId;
	            var startTime=$("#startTime").val();
                var endTime=$("#endTime").val();
                var countyId = $("#countyId").val();
                var regionName = $("#countyId option:selected").text();
	            var isChooseMap = $("input[name='isChooseMap']:checked").val();
	            var cityId=$("#cityId").val();
	            if(isNull(cityId)){
                    cityId="25";
                }
                if(isNull(mgrId)){
                    layer.msg("未获取到项目编号，请重新加载");
                    return false;
                }
		        if(isChooseMap==1){
		        	$("#regionChoose").show();
		            var url=mapManage+"?cityId="+cityId+"&mgrId="+mgrId+"&sendStart="+startTime+"&sendEnd="+endTime
		            		+"&scopeType="+isChooseMap+"&countyId="+countyId+"&mgrState="+"2"+"&checkState="+"2"
		            		+"&regionName="+encodeURI(regionName);
	                url=encodeURI(url); 
		            layer.open({
	                    title: '选取发送区域',
	                    type: 2,
	                    content: [url,'no'],
	                    area: ['1000px', '450px'],
	                    scrollbar: false
	                });
		        }else if(isChooseMap==2){
		            var url="/countyManage.html?cityId="+cityId+"&mgrId="+mgrId+"&sendStart="+startTime+"&sendEnd="+endTime
		            		+"&scopeType="+"0"+"&countyId="+countyId+"&mgrState="+"2"+"&checkState="+"2";
		            layer.open({
	                    title: '选取发送区域',
	                    type: 2,
	                    content: url,
	                    area: ['1000px', '550px'],
	                    scrollbar: true
	                });
		        }
            });
            //插入提交
            $('#submit').on('click', function () {
                var cityId=$("#cityId").val();
                if (isNull(cityId)) {
					cityId="25";
                }
                var countyId = $("#countyId").val();
                var name = $("#name").val();
                var extId=$("#extId").val();
                var startTime=$("#startTime").val();
                var endTime=$("#endTime").val();
                var content=$("#content").val();
                var localDate=$("input[name='localDate']:checked").val();
                var isThreshold = 0;
                $("input:checkbox[name='isThreshold']:checked").each(function () {
                    isThreshold += parseInt($(this).val());
                });
                var cycleThreshold=0;
                var cycle;
                if(isThreshold==2||isThreshold==3){
                	//var cycle = $("input[name='cycle']:checked").val();     //发送周期
                	cycle = $("#cycle").val();
                	cycleThreshold=$("#cycleThreshold").val();
                }
                var isChooseMap = $("input[name='isChooseMap']:checked").val();
		        //var xiangmuid=$("#xiangmuid").val();
		        var xiangmuid=xiangmuId;
                var quyuid=$("#quyuid").val();
                var quyutype=$("#quyutype").val();
                var quyudetail=$("#quyudetail").val();
                var scopeType = $("input[name='isChooseMap']:checked").val();
                var param = {
                    cityId: cityId,
                    countyId: countyId,
                    name: name,
                    extId: extId,
                    startTime: startTime,   //项目开始时间
                    endTime: endTime,//结束时间
                    isLocal: $("input[name='isLocal']:checked").val(),//是否本地发送
                    threshold: $("#threshold").val(),  //全部阀值
                    isThreshold: isThreshold,
                    content:content,
                    mgrId:xiangmuid,
                    regionId:quyuid,
                    regionType:quyutype,
                    regionTypeValue:quyudetail,
                    cycle:cycle,
                    cycleThreshold: cycleThreshold,//周期阀值
                    localDate:localDate,
                    flag: "modify"
                };
                var index = layer.load(1, {shade: [0.1,'#fff'] });//0.1透明度的白色背景
                var url='/mgrTemplate/configureMgrTemplate';
                $.ajax({
                    type: 'post',
                    data: param,
                    url: url,
                    async: false,
                    beforeSend: function () {
                        if (isNull(name)) {
                            layer.msg("项目名称不能为空");
                            return false;
                        }
                        if (startTime == null || startTime == "") {
                            layer.msg("发送开始时间不能为空");
                            return false;
                        }
                        if (endTime == null || endTime == "") {
                            layer.msg("发送结束时间不能为空");
                            return false;
                        }
                        if(isNull($("#threshold").val())){
                        	alert("1111");
                        }
                        if (!checkRate($("#threshold").val())) {
                            layer.msg("阀值必须为数字");
                            return false;
                        }
                        if (isNull(content)) {
                            layer.msg("短信内容不能为空");
                            return false;
                        }
                        if (isNull(xiangmuid)||isNull(quyuid)||isNull(quyutype)||isNull(quyudetail)) {
                            layer.msg("区域信息有误，请重新选择区域");
                            return false;
                        }
                        if (startTime>=endTime) {
                            layer.msg("发送结束时间不能小于等于开始时间");
                            return false;
                        }
                        if(flagMgr!=0){
                    		layer.msg("项目名重复，请修改");
                            return false;
                    	}
                        if(name.length>20){
			              layer.msg("项目名过长，请修改");
			              return false;
			            }
                    },
                    success: function (json) {
                        if (json.code == 0) {
                            layui.use('layer', function () {
                                layer.msg('添加成功,点击确认返回短信项目维护界面', {
                                    time: 0 //不自动关闭
                                    , btn: ['确定']
                                    , yes: function (index2) {
                                    	layer.close(index);
                                        layer.close(index2);
                                        location.href = "smsMgrTemplateManage.html";
                                    }
                                });
                            }); 
                        }else {
                        	layer.close(index);
                            layer.msg(json.msg);
                        }
                    },
                    complete: function () {

                    },
                    error: function (data) {
                    	layer.close(index);
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                }); 
            });
            $('#nextStep').on('click', function () {
				var cityId=$("#cityId").val();
				if (isNull(cityId)) {
					cityId="25";
                }
                var countyId = $("#countyId").val();
                var name = $("#name").val();
                judgeMgrName(name);
                var extId=$("#extId").val();
                
                
                var startTime=$("#startTime").val();
                var endTime=$("#endTime").val();
                var content=$("#content").val();
                var localDate=$("input[name='localDate']:checked").val();
                var isThreshold = 0;
                $("input:checkbox[name='isThreshold']:checked").each(function () {
                    isThreshold += parseInt($(this).val());
                });
                var cycleThreshold=0;
                var cycle;
                if(isThreshold==2||isThreshold==3){
                	//var cycle = $("input[name='cycle']:checked").val();     //发送周期
                	cycle=$("#cycle").val();
                	cycleThreshold=$("#cycleThreshold").val();
                }
                var isChooseMap = $("input[name='isChooseMap']:checked").val();
		        //var xiangmuid=$("#xiangmuid").val();
		        var xiangmuid=xiangmuId;
                var quyuid=$("#quyuid").val();
                var quyutype=$("#quyutype").val();
                var quyudetail=$("#quyudetail").val();
                var scopeType = $("input[name='isChooseMap']:checked").val();
                var param = {
                    cityId: cityId,
                    countyId: countyId,
                    name: name,
                    extId: extId,
                    startTime: startTime,   //项目开始时间
                    endTime: endTime,//结束时间
                    isLocal: $("input[name='isLocal']:checked").val(),//是否本地发送
                    threshold: $("#threshold").val(),  //全部阀值
                    isThreshold: isThreshold,
                    content:content,
                    tabindex:"0",
                    mgrId:xiangmuid,
                    regionId:quyuid,
                    regionType:quyutype,
                    regionTypeValue:quyudetail,
                    cycle:cycle,
                    cycleThreshold: cycleThreshold,//周期阀值
                    localDate:localDate,
                    mgrFlag:"1",
                    flag: "insert"
                };
                var index = layer.load(1, {shade: [0.1,'#fff'] });
                var url='/mgrTemplate/configureMgrTemplate';
                $.ajax({
                    type: 'post',
                    data: param,
                    url: url,
                    async: false,
                    beforeSend: function () {
                        if (isNull(name)) {
                            layer.msg("项目名称不能为空");
                            layer.close(index);
                            return false;
                        }
                        if (startTime == null || startTime== "") {
                            layer.msg("发送开始时间不能为空");
                            layer.close(index);
                            return false;
                        }
                        if (endTime == null || endTime == "") {
                            layer.msg("发送结束时间不能为空");
                            layer.close(index);
                            return false;
                        }
                        if (!checkRate($("#threshold").val())) {
                            layer.msg("阀值必须为数字");
                            layer.close(index);
                            return false;
                        }
                        if (isNull(content)) {
                            layer.msg("短信内容不能为空");
                            layer.close(index);
                            return false;
                        }
                        if (startTime>=endTime) {
                            layer.msg("发送结束时间不能小于等于开始时间");
                            layer.close(index);
                            return false;
                        }
                        if(flagMgr!=0){
                    		layer.msg("项目名重复，请修改");
                    		layer.close(index);
                            return false;
                    	}
                    	if(name.length>20){
			              layer.msg("项目名过长，请修改");
			              layer.close(index);
			              return false;
			            }
                    },
                    success: function (json) {
                        if (json.code == 0) {
                            layui.use('layer', function () {
                                layer.msg('项目添加成功,点击确认配置短信项目发送范围', {
                                    time: 0 //不自动关闭
                                    , btn: ['确定']
                                    , yes: function (index2) {
                                    	layer.close(index);
                                    	layer.close(index2);
                                        $(".layui-form-item").css("display","none");
									   	$("#sendLimit").css("display","inline");
									   	$("#chooseSendLimit").css("display","inline");
									   	$("#ditu").css("display","inline");
									   	chooseSendLimitType();
                                    }
                                });
                            }); 
                        }else {
                        	layer.close(index);
                            layer.msg(json.msg);
                        }
                       
                       
                    },
                    complete: function () {

                    },
                    error: function (data) {
                    	layer.close(index);
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                }); 
            });
            
            
            //选择发送范围方式
            function chooseSendLimitType(){
				var mgrId=xiangmuId;
	            var startTime=$("#startTime").val();
                var endTime=$("#endTime").val();
                var countyId = $("#countyId").val();
                var regionName = $("#countyId option:selected").text();
	            var isChooseMap = $("input[name='isChooseMap']:checked").val();
	            var cityId=$("#cityId").val();
	            if(isNull(cityId)){
                    cityId="25";
                }
                if(isNull(mgrId)){
                    layer.msg("未获取到项目编号，请重新加载");
                    return false;
                }
	            
		        if(isChooseMap==1){
		        	$("#regionChoose").show();
		        	//alert(111);
		        	qryPathName();
		            var url="../areaManage"+mapManage+"?cityId="+cityId+"&mgrId="+mgrId+"&sendStart="+startTime+"&sendEnd="+endTime
		            		+"&scopeType="+isChooseMap+"&mgrState="+"2"+"&checkState="+"2"+"&flag="+"insert";
		          	if(null!=countyId&&''!=countyId){
		          		url = url +"&countyId="+countyId;
	                }
	                if(null!=regionName&&''!=regionName){
	                	url = url +"&regionName="+encodeURI(regionName);
	                }
	                url=encodeURI(url); 
		            $('iframe').attr('src', url);
		            
		        }else if(isChooseMap==2){
		        $("#regionChoose").hide();
		        	
		           var url="../areaManage/countyManage.html?cityId="+cityId+"&mgrId="+mgrId+"&sendStart="+startTime+"&sendEnd="+endTime
		            		+"&scopeType="+"0"+"&mgrState="+"2"+"&checkState="+"2"+"&flag="+"insert"; 
		           if(null!=countyId&&''!=countyId){
		          		url = url +"&countyId="+countyId;
	               }
		           $('iframe').attr('src', url);
		        }
						
            }
            
            //身份识别
            $(document).ready(function () {
                getMgrId();
                $.ajax({
                    type: 'post',
                    async: false,
                    url: '/util/findUser',
                    success: function (json) {
                        user=json;
                        console.info(json);
                        if(json.specialFlag == 1){
                        	mapManage = "/xuYiMapManage.html";
                        }
                        if (json.duty == 1) {//地市
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            var data2 = selectCountyId(json.cityId);
                            appendCounty(data2);
                            //var data1 = selectMgrInfo(json.cityId);
                            //appendMgr(data1);
                            var data3 = selectExtInfo(json.cityId);
                            appendExtId(data3);
                            form.render();
                        } else if (json.duty == 2) {//项目
                            //appendMgr(json.list);
                            var data2 = selectCountyId(json.cityId);
                            appendCounty(data2);
                            var data3 = selectExtInfo(json.cityId);
                            appendExtId(data3);
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            $("#countyId").val(json.countyId);
                            $("#countyId").attr("disabled", true);
                            form.render();
                        }else if (json.duty == 3) {//区县
                            $("#cityId").val(json.cityId);
                            $("#cityId").attr("disabled", true);
                            //var data = selectMgrInfo(json.countyId);
                            //appendMgr(data);
                            var data2 = selectCountyId(json.cityId);
                            appendCounty(data2);
                            var data3 = selectExtInfo(json.cityId);
                            appendExtId(data3);
                            $("#countyId").val(json.countyId);
                            $("#countyId").attr("disabled", true);
                            form.render();
                        }else if(json.duty == 4){
                            if(json.cityId==25){//省权限
                            
                            }else if(json.cityId!=25&&checkStr(json.countyId)==""){//地市权限
	                            $("#cityId").val(json.cityId);
	                            $("#cityId").attr("disabled", true);
	                            var data2 = selectCountyId(json.cityId);
	                            appendCounty(data2);
	                            //var data1 = selectMgrInfo(json.cityId);
	                            //appendMgr(data1);
	                            var data3 = selectExtInfo(json.cityId);
                                appendExtId(data3);
	                            form.render();
                            }else if(json.cityId!=25&&checkStr(json.countyId)!=""){//区县权限
	                            $("#cityId").val(json.cityId);
	                            $("#cityId").attr("disabled", true);
	                            //var data = selectMgrInfo(json.countyId);
	                            //appendMgr(data);
	                            var data2 = selectCountyId(json.cityId);
	                            appendCounty(data2);
	                            var data3 = selectExtInfo(json.cityId);
                                appendExtId(data3);
	                            $("#countyId").val(json.countyId);
	                            $("#countyId").attr("disabled", true);
	                            form.render();
                            }
                        } 
                    }, error: function () {
                        layer.msg('系统异常，请联系管理员处理!');
                    }
                });
            });
            //校验字符串
			function checkStr(str,defaultVal){
				if (typeof(str) == "undefined" || str == null || str == "null") {
					if (defaultVal == undefined) {
						str = "";
					} else {
						str = defaultVal;
					}
				}
				return str;
		    }
        });
    </script>
</head>
<body>
<div class="layui-html-limit">
    <!--container-->
    <div class="layui-content-body">
        <div class="scroll-box">
            <div class="breadcrumb-box">
              <span class="layui-breadcrumb" lay-separator="|">
                  <a href="javascript:returnIndex2()">首页&nbsp;</a>
                  <a href="#"> &nbsp;项目维护管理&nbsp; </a>
                  <a href="#"> &nbsp;短信项目维护&nbsp;</a>
                  <a href="#"> &nbsp;短信项目维护添加&nbsp; </a>
              </span>
            </div>
            <div class="content-box" style="height:100%;width:100%;">
                <div class="layui-form layui-form-pane" style="height:100%;width:100%;">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:120px;">省份</label>
                            <div class="layui-input-block" style="width:180px;margin-left:120px;">
                                <input type="text" name="province" lay-verify="required" value="江苏"
                                       autocomplete="off" class="layui-input" disabled >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:120px;">地市</label>
                            <div class="layui-input-block" style="width:180px;margin-left:120px;">
                                <select name="cityId" lay-filter="cityId" id="cityId">
                                    <option value="">全部</option>
                                    <option value="11">苏州</option>
                                    <option value="12">淮安</option>
                                    <option value="13">宿迁</option>
                                    <option value="14">南京</option>
                                    <option value="15">连云港</option>
                                    <option value="16">徐州</option>
                                    <option value="17">常州</option>
                                    <option value="18">镇江</option>
                                    <option value="19">无锡</option>
                                    <option value="20">南通</option>
                                    <option value="21">泰州</option>
                                    <option value="22">盐城</option>
                                    <option value="23">扬州</option>
                                    <option value="25">省级</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label" style="width:120px;">区县</label>
                            <div class="layui-input-block" style="width:180px;margin-left:120px;">
                                <select name="mgrcountyId" lay-filter="countyId" id="countyId">
                                   <option value="">全部</option>
                                </select>
                            </div>
                        </div>
                     </div>
                     <div class="layui-form-item" >
                        <div class="layui-block" pane="">
                            <label class="layui-form-label" style="width:120px">项目名称</label>
                            <div class="layui-input-block" style="width:180px;margin-left:120px;">
			                    <input type="text" name="name" id="name" required lay-verify="required"
			                           placeholder="请输入项目名称"
			                           autocomplete="off" class="layui-input">
			                </div>
                        </div>
                    </div>
                     
                       <!--
			            <div class="layui-inline layui-inline-center">
			                <label class="layui-form-label">项目名称</label>
			                <div class="layui-input-block" style="width:150px">
			                    <input type="text" name="name" id="name" required lay-verify="required"
			                           placeholder="请输入项目名称"
			                           autocomplete="off" class="layui-input">
			                </div>
			            </div>
                     
                       <div class="layui-inline ">
				            <label class="layui-form-label">短信扩展码</label>
				            <div class="layui-input-block" style="width:150px">
				                <select name="extId" lay-filter="extId" id="extId">
				                    <option value="">请先选择地市</option>
				                </select>
				            </div>
				        </div> -->
				    <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label" style="width: 120px">发送起止时间</label>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="startTime" autocomplete="off" class="layui-input"
                                       placeholder="请选择开始时间" lay-verify="required" style="width:180px">
                            </div>
                            <div class="layui-form-mid">-</div>
                            <div class="layui-input-inline">
                                <input type="text" name="date" id="endTime" autocomplete="off" class="layui-input"
                                       placeholder="请选择结束时间" lay-verify="required" style="width:180px">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" id="sendLimit" style="display:none;">
                    <label class="layui-form-label" style="width: auto;">发送区域设置</label>
                        <div class="layui-input-block">
                        	<input class="radioItem" lay-filter="gis" type="radio" name="isChooseMap" title="行政区域选择" onclick="ChooseRadio(this)" value="2"  checked="checked">
                            <input class="radioItem" lay-filter="gis" type="radio" name="isChooseMap" title="圈画发送范围" onclick="ChooseRadio(this)" value="1">
                            <div class="layui-form-item" id="ditu" style="display:none;">
	                            <div class="layui-inline">
	                                <!-- <button class="layui-btn layui-btn-normal" style="margin-left: 120px;" id="ditubtn" >
	                                    <i class="layui-icon">&#xe608;</i> 选择发送区域
	                                </button> -->
	                                <input type="hidden" class="layui-myinput" style="width:100px" id="xiangmuid" value="项目编码" disabled />
	                                <input type="hidden" class="layui-myinput" style="width:100px" id="quyuid" value="区域编码" disabled/>
	                                <input type="hidden" id="quyutype" disabled/>
	                                <input type="hidden" id="quyudetail" disabled/>
	                                <div id="xiangmuvalue" style="float: right;text-align: center;padding-left: 15px;margin-top: 8px;"></div>
	                            </div>
	                            <!-- <button class="layui-btn" id="submit">立即提交</button> -->
                        	</div> 
                        </div>
                    </div>
                 	<br>
<!--                    <div id= "regionChoose" style="display:none;">-->
<!--                    <div class="layui-inline">-->
<!--                            <label class="layui-form-label" style="width:120px;">路线:</label>-->
<!--                            <div class="layui-input-block" style="width:180px;margin-left:120px;">-->
<!--                                <select name="pathName" lay-filter="pathName" id="pathName">-->
<!--                                    -->
<!--                                </select>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                        <div class="layui-inline">-->
<!--                            <label class="layui-form-label" style="width:120px;">点位:</label>-->
<!--                            <div class="layui-input-block" style="width:180px;margin-left:120px;">-->
<!--                                <select name="subStationName" lay-filter="subStationName" id="subStationName">-->
<!--                                   <option value="">请先选择路线</option>-->
<!--                                </select>-->
<!--                            </div>-->
<!--                        </div>-->
<!--                     <div class="layui-inline" >-->
<!--                        <div class="layui-block" pane="">-->
<!--                            <label class="layui-form-label" style="width:120px">点位名称:</label>-->
<!--                            <div class="layui-input-block" style="width:180px;margin-left:120px;">-->
<!--			                    <input type="text" name="regionName" id="regionName" required lay-verify="required"-->
<!--			                           placeholder="请输入点位名称"-->
<!--			                           autocomplete="off" class="layui-input">-->
<!--			                </div>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                    <div class="layui-inline" pane="">-->
<!--                            <button class="layui-btn layui-btn-normal" id="query">查&nbsp;询</button>-->
<!--                    </div>-->
<!--                    </div>-->
                    
                    <br>
                    <div class="layui-form-item" style="display:none;width:100%;height:100%;" id="chooseSendLimit">
	                        	<!-- <iframe frameborder="0" name="show" scrolling="no"
			            		style="width:1250px;height:530px;border:1px solid green;"></iframe> -->
			            		<iframe frameborder="0" name="show" scrolling="no"
			            		style="width:100%;height:80%;"></iframe>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label"  style="width: auto;">号码发送范围</label>
                            <div class="layui-input-block">
                                <input type="radio" name="isLocal" value="0" title="本地" lay-filter="localDate1">
                                <input type="radio" name="isLocal" value="1" title="外地" lay-filter="localDate1" checked>
                                <input type="radio" name="isLocal" value="2" title="本地+外地" lay-filter="localDate1">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item" id="local">
                        <div class="layui-block" pane="">
                            <label class="layui-form-label" style="width: auto">号码保存时间</label>
                            <div class="layui-input-block">
                                <input type="radio" name="localDate" value="1" title="1天" checked="">
                                <input type="radio" name="localDate" value="3" title="3天">
                                <input type="radio" name="localDate" value="7" title="7天">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"  style="width: auto;">短信阀值设置</label>
                        <div class="layui-inline" style="height:40px">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <input type="checkbox" name="isThreshold" title="短信发送总量" value="1" lay-filter ="thresholdSwitch" >
                             	</div>
                              	<div class="layui-inline" pane="">
                                    <label class="layui-form-label" style="width: 150px">短信发送总条数:</label>
                                    <div class="layui-input-inline" style="width: 100px">
                                        <input type="text" id="threshold" placeholder="请输入"
                                               autocomplete="off" class="layui-input" value="0" disabled>
                                    </div>
                                </div>
                                <div class="layui-inline">条</div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label" style="width: auto;opacity: 0;">短信阀值设置</label>
                        <div class="layui-inline" >
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <input type="checkbox" name="isThreshold" title="周期发送数量" value="2" lay-filter ="cycleThresholdSwitch">
                                </div>
                                <!-- 
                                <div class="layui-inline" pane="">
                                    <input type="radio" name="cycle" value="4" title="按日">
                             	</div>
                             	 -->
                             	  <input type="hidden" name="cycle" id="cycle" value="4" title="按日">
                                        <div class="layui-inline" pane="">
                                            <label class="layui-form-label" style="width: 150px;">日短信发送条数:</label>
                                            <div class="layui-input-inline" style="width: 100px;">
                                                <input type="text"
                                                       placeholder="请输入" id="cycleThreshold"
                                                       autocomplete="off" class="layui-input" lay-verify="number"
                                                       value="0" disabled>
                                            </div>
                                        </div>
                                        <div class="layui-inline">条</div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <div class="layui-block">
                            <label class="layui-form-label" style="width: auto">发送短信内容</label>
                            <div class="layui-input-block">
                            	<textarea placeholder="请输入内容" class="layui-textarea" style="width: 50%"
                                      id="content"></textarea>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <!-- <button class="layui-btn" id="submit">立即提交</button> -->
                        <button class="layui-btn" id="nextStep">下一步</button>
                    </div>
                </div>
                <!-- <div  id="LimitChoose" style="display:none;">
                	<div class="layui-form layui-form-pane">
					<div class="layui-inline">
                            <label class="layui-form-label">省份</label>
                            <div class="layui-input-block" style="width:150px">
                                <input type="text" name="province" lay-verify="required" value="江苏"
                                       autocomplete="off" class="layui-input" disabled >
                            </div>
                    </div>
                    </div>
				</div> -->
            </div>
        </div>
    </div>
</div>
</body>
</html>